﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace Mari.SmartHotel.Controls.Converters
{
    public class DivideConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double intValue = (double)value;
            if (intValue == 0) return 0;
            double divisor = Double.Parse(parameter.ToString());
            return intValue / divisor;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double intValue = (double)value;
            double divisor = Double.Parse(parameter.ToString());
            return intValue * divisor;
        }
    }
}